﻿using MicroDb.Options;

using Microsoft.Extensions.Logging;

using MySqlConnector;

using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;

namespace MicroDb.MySql
{
    public class MySqlExecute : SqlExecute
    {
        private readonly string connectionString;
         
        public MySqlExecute(MicroDbOptions microDb)
        {
            this.connectionString = microDb.DbConnectionString;
        }

        protected override DbConnection CreateDbConnection()
        {
            return new MySqlConnection(connectionString);
        }

        protected override DbParameter[] CreateParameters(IDictionary<string, object> parameters)
        {
            return parameters.Select(a => new MySqlParameter(a.Key, a.Value)).ToArray();
        }

    }
}
